package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class ScrollPaneExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        // 创建多个 Label 以便内容超出视图区域
        VBox content = new VBox();
        for (int i = 1; i <= 50; i++) {
            content.getChildren().add(new Label("Label " + i));
        }

        // 创建 ScrollPane 并设置其内容
        ScrollPane scrollPane = new ScrollPane(content);

        // 创建布局并添加 ScrollPane
        Scene scene = new Scene(scrollPane, 300, 200);

        primaryStage.setTitle("ScrollPane Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}